package sort;
/*
 * bron: http://www.jeggu.com/2010/09/quick-sort-implementation-in-java.html
 */
public class Quicksort {

	public void quickSort(int[] a, int lo, int hi) {
		// lo is the lower index and hi is the higher index
		int i = lo;
		int j = hi;

		// Comparison element
		int x = a[(lo + hi) / 2];
		do {
			while (a[i] < x)
				i++;
			while (a[j] > x)
				j--;
			if (i <= j) {
				int h = a[i];
				a[i] = a[j];
				a[j] = h;
				i++;
				j--;
			}
		} while (i <= j);
		if (lo < j)
			quickSort(a, lo, j);
		if (i < hi)
			quickSort(a, i, hi);
	}

}



